"""
文件的读取操作
"""
import time

# open(name,mode='r', encoding=None)
f = open('test.txt', 'r')
print(type(f))
# 读取文件-read()
print(f.read(10))
print(f.read())
print("----------------------------------")
# 读取文件-readlines()
f.seek(0)
lines = f.readlines()
print(lines)
f.seek(0)
# 读取文件-readline()
line = f.readline()
print(line)
f.seek(0)
# 读取文件-迭代器
for line in f:
    print(line)
# 关闭文件
# time.sleep(10000)
f.close()
# with open('test.txt', 'r') as f:-可自动关闭文件
with open('test.txt', 'r') as f:
    for line in f:
        print(line)

